package com.example.back.controller;
import com.example.back.common.Result;
import com.example.back.entity.User;
import com.example.back.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/User")
public class UserController {
    @Resource
    private UserService userService;

    //查询密码和用户名
    @PostMapping("/login")//@RequestBody接收Jason格式参数
    public Result login(@RequestBody User user){
        User result = userService.getByUser(user.getUsername(),user.getPassword());
        if (result == null){
            return Result.error("用户名或密码错误");
        }
        return Result.success(result,"登录成功");
    }

}
